﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using Microsoft.Practices.Unity;

namespace WindowsFormsApplication2
{

    public class DbSettings : IDbSettings
    {
        string _connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;

        public string ConnectionString
        {
            get
            {
                return _connectionString;
            }
        }
    }

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IUnityContainer container = new UnityContainer();

            container.RegisterType<IDbSettings,DbSettings>(new ContainerControlledLifetimeManager());

            container.RegisterType<IRepository<Contact>, ContactsRepository>(new ContainerControlledLifetimeManager());
            container.RegisterType<IRepository<TaskItem>, TaskItemsRepository>(new ContainerControlledLifetimeManager());
            container.RegisterType<IRepository<Product>, ProductsRepository>(new ContainerControlledLifetimeManager());
           
            Application.Run(container.Resolve<Form1>());
        }
    }
}
